from PyPDF2 import PdfFileReader, PdfFileWriter

def rotate_pages(pdf_path):
    pdf_writer = PdfFileWriter()
    pdf_file = PdfFileReader(pdf_path)
    for page_num in range(pdf_file.numPages):
        page = pdf_file.getPage(page_num)
        #页面顺时针旋转270度
        new_page = page.rotateClockwise(270)
        pdf_writer.addPage(new_page)

    with open('new_dogs.pdf', 'wb') as fh:
        pdf_writer.write(fh)


if __name__ == '__main__':
    path = 'dogs.pdf'
    rotate_pages(path)
